/** @file testsdlib.c
 * \brief Source file utilizzato come testing per sdlib.
 * Attualmente contiene tutti i testing implementati.
 *
 *  Created on: Feb 27, 2012
 * @author: Francesco Corvino
 */
#include "ctesting.h"


void setTestEnviromentEmpty(DescRequest * env){

}

void executeTestSdlib(){
	char* paths[3] = {"./lib1.so", "./lib2.so", "./lib3.so" };
	char* names[3] = {"lib1", "lib2", "lib3" };
	void (* fptr)(char*);

	FacRcv_writeStr("Testing sdlib (select dinamic library module)\n");

	initialize();
	setLoggingFunc(logsimplefunction);

	DescrLib lib1;
	lib1.path = paths[0]; lib1.name = names[0]; lib1.type = 2;

	char msg[255]; sprintf(msg,"cerco la libreria %s in %s \n", lib1.name , lib1.path);
	FacRcv_writeStr(msg);
	loadLib(&lib1);

	if(lib1.libpointer==NULL) FacRcv_writeStr("non la trovo");
	else {
		fptr = (void (*)(char*)) lib1.libpointer;
		(*fptr)("come stai?");
	}

	terminate();
}

void executeTestAppData(void){

}

SimpleDescCommand defcmdtest[] = {
		{"test1","Effettua un test sulle sdlib",executeTestSdlib},
		{"testAppData","Testa l'utilizzo delle risorse applicative",executeTestAppData}
};

void testsdlib_LoadAllCommands(){
	int i;
	for(i=0;i<2;i++){
		HiddenType helpfnc = { defcmdtest[i].helpstr, getHiddenTypeToString };
		FactApp_addCommand(invoke_defineCompleteCMD(
				defcmdtest[i].namecmd,defcmdtest[i].execfnc,&helpfnc,NULL));
	}
}


